package com.michir.projects.jms.mocks;

import java.io.Serializable;

import javax.jms.JMSException;
import javax.jms.ObjectMessage;

import org.mockito.Mockito;

/**
 * {@link ObjectMessage} Mocker: uses {@link Mockito}.
 * 
 * @author michir
 */
public class ObjectMessageMocker {

	/**
	 * POJO constructor, use {@link #mock(Serializable)} factory method.
	 */
	private ObjectMessageMocker() {}

	/**
	 * {@link ObjectMessage} mock factory.
	 * @param serializable instance to set to {@link ObjectMessage}
	 * @return mocked {@link ObjectMessage}
	 * @throws JMSException
	 */
	public static ObjectMessage mock(Serializable serializable) throws JMSException {
		ObjectMessage message = Mockito.mock(ObjectMessage.class);
		Mockito.doNothing().when(message).setObject(serializable);
		Mockito.when(message.getObject()).thenReturn(serializable);
		return message;
	}
}
